## Local Functions ##

from Support.Device.Simulator_Init import *
from PyDevice import *
from Py_Lauterbach import *
TTB_Print = 1

def CycleIgnition():
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive: Cycle Ignition")
		
	#Switch the ignition off.
    Set(SIMULATOR, 0, "Key Switch State", KeySwitchState.Off_Lock)
	
    Wait(3000)
   
    #Switch the ignition on.
    Set(SIMULATOR, 0, "Key Switch State", KeySwitchState.Run)
    
    Wait(3000)
	
def WriteSim(signal, value):
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive Memory Write: %s = %s" % (signal, str(value)))
		
    Set(SIMULATOR, 0, signal, value)
	
def ReadSim(signal, low, high, tstNum, des):	
    value = Get(SIMULATOR,0, signal)
    varName = "%s %s" % ( signal , tstNum)
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive Memory Read: %s = %s (l %s, h %s)" % (signal, str(value), str(low), str(high)))	
    TTB_Results(varName,0, des, value, low, high)	
	
def IgnOn():
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive: Turn Ignition ON")
		
    Set(SIMULATOR, 0, "Key Switch State", KeySwitchState.Run)
    Wait(1000)
	
def IgnOff():
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive: Turn Ignition OFF")
    Set(SIMULATOR, 0, "Key Switch State", KeySwitchState.Off_Lock)	
    Wait(1000)	

def BatOn():
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive: Turn Battery ON")
    Set(SIMULATOR, 0, "Battery Control State", BatteryState.On)
    Wait(1000)	

def BatOff():
    if TTB_Print: 
        TTB_Log(MISC, "TestDrive: Turn Battery OFF")
    Set(SIMULATOR, 0, "Battery Control State", BatteryState.Off)
    Wait(1000)	